Repository navigation
Conversation
Parquet statistics do not track NaN values, so data files written by PyIceberg never carried nan_value_counts. The strict metrics evaluator reads a missing NaN count as "no NaN values", so a delete such as `value < 5.0` dropped whole files and lost NaN rows that do not match the filter. Count NaN values of float and double columns while writing, as the Java Parquet writers do.
…-counts # Conflicts: # tests/catalog/test_catalog_behaviors.py
|
I'd like a review on this one from @Fokko or @kevinjqliu. It closes #4130: data files written by PyIceberg never carried |
…-counts # Conflicts: # tests/catalog/test_catalog_behaviors.py
|
Since PyIceberg never writes |
…ue-counts # Conflicts: # pyiceberg/io/pyarrow.py # tests/io/test_format_writers.py
|
#4401 landed on main with NaN counts for top-level float and double columns, so I merged main into this branch (6670ecb) and rebuilt the change on top of it. What's left is the part #4401 leaves for later: For example, if a file has no NaNs in |
Closes #4130
Rationale for this change
Parquet statistics do not track NaN values. #4401 now counts NaNs while writing, but only for top-level float and double columns, and its description leaves nested fields for a follow-up. This PR is that follow-up. After merging main into this branch, it extends
_nan_value_counts_from_arrowto also count float and double fields inside structs, list elements, and map keys and values.Without nested counts, a file whose
s.vhas no NaNs cannot be pruned ons.v IS NAN, since a missing count means "unknown". With this change the writer recordsnan_value_counts[s.v] = 0and the scan skips the file.The helper now takes the file's Iceberg schema and walks it in the same way for structs, lists and maps. It still skips columns whose metrics mode is
noneand leaves out columns it cannot count. Top-level columns are counted the same way #4401 counts them. Files without float or double fields do no extra work.Are these changes tested?
Yes.
tests/io/test_format_writers.py::test_nan_value_counts: counts for top-level float and double columns, a struct field, list elements and map values across twowrite()calls, plus a zero count for a column with no NaNs. Report NaN value counts for written Parquet files #4401's accumulation and metrics-mode tests still pass unchanged.tests/catalog/test_catalog_behaviors.py:delete("value < 5.0")on a file with[1.0, NaN]keeps the NaN row. This was the reproduction from Data files written by PyIceberg have no nan_value_counts, sodelete()drops NaN rows that do not match the filter #4130. It passes on main since Report NaN value counts for written Parquet files #4401 and stays as a regression test.Are there any user-facing changes?
Data files written by PyIceberg now include
nan_value_countsfor nested float and double fields, so scans can prune on them.